﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class registration_step3 : DAO.ESWebUserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        InitializeUI();
        setAttributes();
        LoadLangs();
    }

    private void setAttributes()
    {
        tbContactPerson.Attributes.Add("validate", "true");
        tbRegLang.Attributes.Add("validate", "true");
        tbRegLang.Attributes.Add("multiple", "multiple");
        //tbCaptcha.Attributes.Add("style", "background-image:url(design_img/1.jpg); text-align:center; border:none;font-weight:bold; font-family:Modern");
    }
    protected override void InitializeUI()
    {
        long langId = DAO.Connection.DEFAULT_LANGUAGE;
        if (Session["language"] != null)
            long.TryParse(Session["language"].ToString(), out langId);

        this.LangId = Convert.ToInt32(langId);
    }

    private void LoadLangs()
    {
        using (SqlConnection conn = new SqlConnection(DAO.Connection.CONN_STRING1))
        {
            conn.Open();
            using (SqlCommand cmd = new SqlCommand("SELECT * FROM dbo.Fn_GetAllPlaces(0, 1000000, 'id', 'asc', 4) WHERE isActive='true' Order By name asc", conn))
            {
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    tbRegLang.Items.Add(new ListItem(dr["name"].ToString() + " - " + dr["short"].ToString().ToUpper(), dr["id"].ToString()));
                }
                dr.Close();
            }
        }
    }
}
